home *** CD-ROM | disk | FTP | other *** search
/ Game Programming in C++ - Start to Finish / GameProgrammingS.iso / Peon / PeonSDK-Win32-1.0.0.exe / {app} / PeonMain / include / SceneCamera.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-11-25  |  3.0 KB  |  115 lines

  1.  
  2. #ifndef __SCENECAMERA_H_
  3. #define __SCENECAMERA_H_
  4. /*
  5. Peon - Win32 Games Programming Library
  6. Copyright (C) 2002-2005 Erik Yuzwa
  7.  
  8. This library is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU Library General Public
  10. License as published by the Free Software Foundation; either
  11. version 2 of the License, or (at your option) any later version.
  12.  
  13. This library is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. Library General Public License for more details.
  17.  
  18. You should have received a copy of the GNU Library General Public
  19. License along with this library; if not, write to the Free
  20. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  21.  
  22. Erik Yuzwa
  23. peon AT wazooinc DOT com
  24. */
  25.  
  26.  
  27. #include "ISceneObject.h"
  28. #include "Vector3.h"
  29. #include "Plane.h"
  30.  
  31. namespace peon
  32. {
  33.     /**
  34.     * This object acts as a wrapper around modifying the view matrix of the
  35.     * scene (aka the view transformation stage of the pipeline). 
  36.     */
  37.     class PEONMAIN_API SceneCamera : public ISceneObject
  38.     {
  39.  
  40.     protected:
  41.         
  42.         /** the "Up" vector */
  43.         Vector3 m_vecUp;
  44.  
  45.         /** the "LookAT" vector */
  46.         Vector3 m_vecLookAt;
  47.  
  48.         /** our six view frustum planes */
  49.         Plane m_oFrustumPlanes[6];
  50.  
  51.  
  52.     public:
  53.         /**
  54.         * Constructor
  55.         */
  56.         SceneCamera();
  57.  
  58.         /**
  59.         * Destructor
  60.         */
  61.         ~SceneCamera();
  62.  
  63.         /**
  64.         * This method is responsible for capturing our current view
  65.         * frustum matrix and dumping the data into 6 planes that 
  66.         * we can query
  67.         */
  68.         void generateViewFrustum();
  69.  
  70.         /**
  71.         * This method is responsible for testing if a sphere has
  72.         * hit a view frustum boundary. 
  73.         * @param x - x position of the sphere
  74.         * @param y - y position of the sphere
  75.         * @param z - z position of the sphere
  76.         * @param float - radius of the sphere
  77.         * @return bool - true if the sphere is inside the frustum
  78.         */
  79.         bool isSphereInFrustum( float x, float y, float z, float fRadius );
  80.  
  81.         /**
  82.         * This method is responsible for setting the perspective
  83.         * matrix for our camera
  84.         * @param fAspect - the aspect ratio of the view
  85.         * @param z_min - the minimum z-plane 
  86.         * @param z_max - the maximum z-plane
  87.         */
  88.         void setPerspectiveProj( float fAspect, float z_min, float z_max );
  89.  
  90.         /**
  91.         * This method sets our camera viewpoint
  92.         * @param vecEye - Vector3 of the eye point
  93.         * @param vecLookAt - Vector3 coordinates of where we're lookin
  94.         * @param vecLookUp - Vector3 coordinates of the up direction
  95.         */
  96.         void setViewMatrix( Vector3& vecEye, Vector3& vecLookAt, Vector3& vecUp);
  97.  
  98.         //this rotates the view around a specified axis.
  99.         void rotateView(float X, float Y, float Z);
  100.  
  101.         
  102.         virtual void updateView();
  103.  
  104.         /**
  105.         * This method can be used to update the view matrix based
  106.         * on the mouse's motion (if need be)
  107.         * @param pEvent - the SDL_Event structure containing the mouse events
  108.         */
  109.         virtual void onMouseEvent( SDL_Event* pEvent );
  110.  
  111.     };
  112. }
  113.  
  114. #endif
  115.